import { Room } from '../../api/Room';
import { Card } from '../base/Card';

export class OfficialSeal extends Card {
	title(room: Room, user: string): string {
		return '官印授予';
	}

	desc(room: Room, user: string): string {
		return '触发场上随机一张官员牌的效果。';
	}

	use(room: Room, user: string, target: string): void {
		var dept = room.getDept(target);
		if (!dept) return;

		var index = Math.floor(Math.random() * dept.fieldCards.length);
		var card = dept.fieldCards[index];
		if (!card) return;
		card.turnStart(room, target);
		card.turnEnd(room, target);
	}

	target(room: Room, user: string): string {
		return 'all';
	}

	priority(room: Room, user: string, target: string): number {
		var dept = room.getDept(target);
		if (!dept) return -1;
		return dept.handCards.length > 0 ? 50 : -1;
	}
}
